package com.myshop.controller;


import com.myshop.entity.Item;
import com.myshop.entity.R;
import com.myshop.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单内部的具体商品展示项(Item)表控制层
 *
 * @author makejava
 * @since 2023-07-21 16:17:58
 */
@RestController
@RequestMapping("item")
@CrossOrigin
public class ItemController {
    /**
     * 服务对象
     */
    @Autowired
    private ItemService itemService;
    @RequestMapping("/query")
    public R query(){
        return R.succ( itemService.list());
    }

    /**
     * 新增订单
     * @param item
     * @return
     */
    @RequestMapping("/insert")
    public R insert(Item item){
        itemService.save(item);
        return R.succ(null);
    }

    /**
     * 删除订单
     * @param id
     * @return
     */
    @RequestMapping("/delete")
    public R delete(Integer id){
        itemService.removeById(id);
        return R.succ(null);
    }
}

